package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhEducation;
import com.yinhe.system.service.IYhEducationService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 职业教育学习档案Controller
 * 
 * @author yinhe
 * @date 2022-09-24
 */
@RestController
@RequestMapping("/system/education")
public class YhEducationController extends BaseController
{
    @Autowired
    private IYhEducationService yhEducationService;

    /**
     * 查询职业教育学习档案列表
     */
    @PreAuthorize("@ss.hasPermi('system:education:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhEducation yhEducation)
    {
        startPage();
        List<YhEducation> list = yhEducationService.selectYhEducationList(yhEducation);
        return getDataTable(list);
    }

    /**
     * 导出职业教育学习档案列表
     */
    @PreAuthorize("@ss.hasPermi('system:education:export')")
    @Log(title = "职业教育学习档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhEducation yhEducation)
    {
        List<YhEducation> list = yhEducationService.selectYhEducationList(yhEducation);
        ExcelUtil<YhEducation> util = new ExcelUtil<YhEducation>(YhEducation.class);
        util.exportExcel(response, list, "职业教育学习档案数据");
    }

    /**
     * 获取职业教育学习档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:education:query')")
    @GetMapping(value = "/{studyRecordId}")
    public AjaxResult getInfo(@PathVariable("studyRecordId") Long studyRecordId)
    {
        return AjaxResult.success(yhEducationService.selectYhEducationByStudyRecordId(studyRecordId));
    }

    /**
     * 新增职业教育学习档案
     */
    @PreAuthorize("@ss.hasPermi('system:education:add')")
    @Log(title = "职业教育学习档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhEducation yhEducation)
    {
        return toAjax(yhEducationService.insertYhEducation(yhEducation));
    }

    /**
     * 修改职业教育学习档案
     */
    @PreAuthorize("@ss.hasPermi('system:education:edit')")
    @Log(title = "职业教育学习档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhEducation yhEducation)
    {
        return toAjax(yhEducationService.updateYhEducation(yhEducation));
    }

    /**
     * 删除职业教育学习档案
     */
    @PreAuthorize("@ss.hasPermi('system:education:remove')")
    @Log(title = "职业教育学习档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{studyRecordIds}")
    public AjaxResult remove(@PathVariable Long[] studyRecordIds)
    {
        return toAjax(yhEducationService.deleteYhEducationByStudyRecordIds(studyRecordIds));
    }
}
